#include "stdio.h"
#include "stdlib.h"
#include "string.h"

#include "fcntl.h"

int main(int argc,char *argv[])
{
    int fd = 0;
    char *filename;
    filename = argv[1];
    short ir,als,ps;
    short databuf[3];

    if (argc != 3)
    {
        printf("Usage:error\r\n");
        return -1;
    }
    

    fd = open(filename,O_RDWR); 
    if (fd  <  0)
    {
        printf("Error opening\r\n");
        return -1;
    }
    
    while (1 )
    {
        read(fd,databuf,sizeof(databuf));
        ir=databuf[0];
        als = databuf[1];   
        ps = databuf[2];

        printf("ir:%d, als:%d, ps:%d\r\n",ir,als,ps);

        usleep(200000);
    }
    
    close(fd);

    return 0;
}